<?php
class b2c_mdl_goods_type_props_value extends dbeav_model{

    const TTL = 7200;//缓存时间
    const REDIS_DB = 1;

    function get_props_value_id_by_name_and_props_id($name,$props_id){
        $redis = kernel::single('base_kvstore_redis2');
        $redis->selects(self::REDIS_DB);

        $key = 'b2c_mdl_goods_type_props_value:'.md5($name).':'.$props_id;
        if($redis->exists($key)){
            return unserialize($redis->get($key));
        }else{
            $data = $this->getList('props_value_id', array('name' => $name, 'props_id' => $props_id));
            $redis->set($key,serialize($data));
            $redis->expire($key,self::TTL);
            return  $data;
        }
    }


    function get_props_value_id_by_name($name){
        $redis = kernel::single('base_kvstore_redis2');
        $redis->selects(self::REDIS_DB);
        $key = 'b2c_mdl_goods_type_props_value:'.md5($name);
        if($redis->exists($key)){
            return unserialize($redis->get($key));
        }else{
            $data = $this->getList('props_value_id', array('name' => $name));
            $redis->set($key,serialize($data));
            $redis->expire($key,self::TTL);
            return  $data;
        }
    }


}
